package com.lyx.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lyx.entity.AirQualityIndex;
import com.lyx.service.AirQualityIndexService;
import com.lyx.service.impl.AirQualityIndexServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lyx
 * @since 2022-02-22
 */
@RestController
@Api(tags = "AirQualityIndex控制器")
@CrossOrigin
public class AirQualityIndexController {

    @Autowired
    AirQualityIndexServiceImpl airQualityIndexService;

    @ApiOperation("分页带条件查询air")
    @GetMapping("/getPageList")
    public Page<AirQualityIndex> getPageList(@RequestParam(value ="did" ,required = false) Integer did
            ,@RequestParam(value = "current",required = true,defaultValue = "1") Integer current,
             @RequestParam(value = "size",required = true,defaultValue = "4")  Integer size){
        Page<AirQualityIndex> air = new Page<>(current, size);
        Page<AirQualityIndex> indexPage = airQualityIndexService.pageSelectAir(air, did);
        return indexPage;
    }

    @ApiOperation("增加air属性")
    @PostMapping("/addAir")
    public boolean addAir(@RequestBody AirQualityIndex air){
        return airQualityIndexService.save(air);
    }

    @ApiOperation("修改air属性")
    @PostMapping("/updateAir")
    public boolean updateAir(@RequestBody AirQualityIndex air){
        return airQualityIndexService.updateById(air);
    }

    @ApiOperation("删除air属性")
    @GetMapping("/deleteAir")
    public boolean deleteAir( Integer id){
        return airQualityIndexService.removeById(id);
    }


}

